package com.tzy.tzyrpcdemoprovider;

import com.tzy.tzyrpccore.annotation.TzyRpcAnnotation;
import com.tzy.tzyrpccore.api.RpcRequest;
import com.tzy.tzyrpccore.api.RpcResponse;
import com.tzy.tzyrpccore.conf.ProviderConf;
import com.tzy.tzyrpccore.provider.ProviderBootStrap;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


@RestController
@SpringBootApplication
@Import(ProviderConf.class) // 导入配置类
public class TzyrpcDemoProviderApplication {
    @Resource
    private ProviderBootStrap providerBootStrap;
    public static void main(String[] args) {
        SpringApplication.run(TzyrpcDemoProviderApplication.class, args);
    }

    @RequestMapping(value = "/", method = RequestMethod.POST)
    public RpcResponse invoke(@RequestBody RpcRequest rpcRequest) {
        return providerBootStrap.invokeMethod(rpcRequest);
    }
}
